#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>

int main()
{
    int test = 10;
    int ret = fork();
    if(ret == 0)
    {
        test = 20;
        printf("修改后test=%d\n ", test);
        while(1)
        {
            printf("我是子进程%d,ppid:%d,test:%d,&test: %p\n\n",getpid(),getppid(),test,&test);
            sleep(1);
        }
    }
    else
    {    
        while(1)
        {
            printf("我是父进程%d,ppid:%d,test:%d,&test: %p\n\n",getpid(),getppid(),test,&test);
            sleep(1);
        }
    }       
    return 0;
}
